//
//  CustomBtn.m
//  Medicine
//
//  Created by laber on 15/5/21.
//  Copyright (c) 2015年 laber. All rights reserved.
//  6plus 1981

#import "CustomBtn.h"

#define cus_height (contentRect.size.height)//按钮高度
#define cus_width (contentRect.size.width)//按钮宽度
#define image_top (cus_height-cus_width-26)/2//按钮图片x距离

@implementation CustomBtn

-(instancetype)init{
    if ([super init]) {
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont systemFontOfSize:FONT_MIDDLE];
    }
    return self;
}

-(CGRect)imageRectForContentRect:(CGRect)contentRect{
//    CGFloat x = (contentRect.size.width-54)/2;
//    if (self.tag == 0) {
//        x =0;
//    }else if(self.tag == 3){
//        x = contentRect.size.width-54;
//    }
    
if (contentRect.size.width > 54) {
        contentRect.size.width = 54;
    }
    return CGRectMake(0, image_top, contentRect.size.width, contentRect.size.width);
}

-(CGRect)titleRectForContentRect:(CGRect)contentRect{
//    CGFloat x = (contentRect.size.width-54)/2;
//    if (self.tag == 0) {
//        x =0;
//    }else if(self.tag == 3){
//        x = contentRect.size.width-54;
//    }
    if (contentRect.size.width > 54) {
        contentRect.size.width = 54;
    }
    return CGRectMake(0, contentRect.size.width+8+image_top, contentRect.size.width, FONT_MIDDLE);
}

@end
